package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

/**
 * 规格实体
 * 用于定义商品的具体规格属性
 */
@Comment("规格")
@Data
@FormAnnotation(title = "规格管理", model = "规格")
@Entity
@Table(name = "nb_spec")
public class Spec extends AbstractEntity {

    @Comment("规格名称")
    @FormField(title = "规格名称", grid = true, required = true)
    @Column(length = 50)
    private String name;

    @Comment("所属规格模型")
    @FieldName
    @FieldConvert
    @FormField(title = "规格模型", type = InputType.select, option = "specModel")
    @ManyToOne(fetch = FetchType.LAZY)
    private ProductModel model;

    @Comment("显示顺序")
    @FormField(title = "排序号", grid = true, type = InputType.el_input_number)
    private Integer sortNum;

    @Comment("规格说明")
    @FormField(title = "备注", type = InputType.textarea)
    @Column(length = 500)
    private String note;
}
